package com.jotton.minnadekakeibo;

import com.jotton.minnadekakeibo.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.*;
import android.widget.Button;
import android.widget.ImageView;
import android.content.*;

public class minnadekakeiboActivity extends Activity implements OnClickListener {
	
	private Context context;
	private lCAnimateMethod cm;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        context = this;
        
        setContentView(R.layout.vmbmain);
        
        View v = this.findViewById(R.id.button2);
 
        cm = new lCAnimateMethod(context);
        cm.setup();
        
        v.setOnClickListener(this);
        
    }

    
    @SuppressWarnings("unused")
	private class lCAnimateMethod
    {
    	private Context mContext;
    	
    	public lCAnimateMethod(Context context)
    	{
    		mContext = context;
    	}
    	
    	ImageView iv;
    	Button btntrans, btnalpha, btnrotate, btnscale, btnmix1, btnmix2;	
    	
    	TranslateAnimation translate;
    	AlphaAnimation alpha;
    	RotateAnimation rotate;
    	ScaleAnimation scale;
    	AnimationSet mix1, mix2;
    	
    	private void setup()
    	{
    		
	        
	        // *** set translate ***
	        // TranslateAnimation(float fromX, float toX, float fromY, float toY)
			translate = new TranslateAnimation(0, 30, 0, 0);
			// set duration to 3000ms
			translate.setDuration(3000);
			// repeat 3 times
			//translate.setInterpolator(new CycleInterpolator(3)); 
			translate.setFillAfter(true);
			
			// *** set alpha ***
			// AlphaAnimation(float fromAlpha, float toAlpha)
			alpha = new AlphaAnimation(1, 0);
			alpha.setDuration(5000);
			alpha.setInterpolator(new CycleInterpolator(3));
			
			// *** set rotate ***
			// RotateAnimation(float from, float to, float pivotX, float pivotY)
			rotate = new RotateAnimation(0, 360, 150, 150);
			rotate.setDuration(3000);
			rotate.setInterpolator(new CycleInterpolator(3));
			
			// *** set scale ***
			// ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)
			scale = new ScaleAnimation(1, 2, 1, 2, 150, 150);
			scale.setDuration(3000);
			scale.setInterpolator(new CycleInterpolator(3));
			
			// *** set mix1 ***
			mix1 = new AnimationSet(true);
			mix1.addAnimation(rotate);
			mix1.addAnimation(scale);
			mix1.setInterpolator(new CycleInterpolator(2));

			// *** set mix2 ***
			mix2 = new AnimationSet(true);
			mix2.addAnimation(rotate);
			mix2.addAnimation(translate);
			mix2.addAnimation(alpha);
			mix2.setInterpolator(new CycleInterpolator(2));
	        
    	}

    	public void Action(View v)
    	{
    		v.startAnimation(translate);
    	}
    }


	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		cm.Action(v);
	}

}